<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "{{%receival}}".
 *
 * @property int $id 序号
 * @property string $money 本次交款金额
 * @property string $comment 备注
 * @property int $created_at 创建时间
 * @property int $updated_at 修改时间
 * @property int $project_id 关联项目id
 * @property int $input_user_id 录入员
 * @property int $valid 1-有效0-无效
 * @property string $invoice_no 发票编号
 * @property int $receive_date 收款日期
 */
class Receival extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%receival}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['money'], 'number'],
            [['created_at', 'updated_at', 'project_id', 'input_user_id', 'valid', 'receive_date'], 'integer'],
            [['comment', 'invoice_no'], 'string', 'max' => 255],
        ];
    }

    public function extraFields()
    {
        $fields['project_name'] = function ($model){
            return $model->project;
        };
        return $fields;
    }

    public function getProject(){
        return $this->hasOne(Project::class,['id'=>'project_id']);
    }
}
